package com.bnz.bnzshop.controller;

import com.bnz.common.utils.PageUtils;
import com.bnz.bnzshop.entity.SpecificationEntity;
import com.bnz.bnzshop.service.SpecificationService;
import com.bnz.pojo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 
 *
 * @author baizhi
 * @email 315104869@qq.com
 * @date 2022-10-30 15:21:50
 */
@RestController
@RequestMapping("shop/specification")
public class SpecificationController {
    @Autowired
    private SpecificationService specificationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("manager:specification:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = specificationService.queryPage(params);

        return R.ok().put("page", page);
    }
    @RequestMapping("/findAll")
    public R all(){
        List<SpecificationEntity> list = specificationService.list();
        return R.ok().put("list",list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
        public R info(@PathVariable("id") String id){

		SpecificationEntity specification = specificationService.getById(id);
        //ConnectionVo info = specificationService.info(id);
        return R.ok().put("specification", specification);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
        public R save(@RequestBody SpecificationEntity specification){

		specificationService.save(specification);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
        public R delete(@RequestBody String[] ids){
        //2020/11/2修改 删除规格和子规格
		//specificationService.removeByIds(Arrays.asList(ids));
          specificationService.deleteIds(ids);
        return R.ok();
    }

}
